<?php
namespace app\models;
use Yii;
use app\models\PlanBill;

class PlanBillItem
{
	public static function getPlanbillid($orderinfoList)
	{
		$query = new \yii\db\Query();

		$planbillidList = $query->select("planbillid")
				  ->from("JXC_PLANBILLITEM")
				  ->where("orderid in(".$orderinfoList.")")
				  ->all();

		$result = array();

		foreach($planbillidList as $planbillid){
			$result[] = $planbillid['planbillid'];
		}

		return implode(",",$result);
	}

	public static function getOrderidByPlannum($plannum)
	{
		$planidList = PlanBill::getPlanidByPlannum($plannum);

		$query = new \yii\db\Query();

		$orderidList = $query->select("orderid as orderinfoid")
							  ->from("JXC_PLANBILLITEM")
							  ->where("planbillid in(".$planidList.")")
							  ->all();

		$result = array();

		foreach($orderidList as $orderid){
			$result[] = $orderid['orderinfoid'];
		}

		return implode(",",$result);
	}
}